home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue53 / ccorn / Listing5.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-12-09  |  867 b   |  40 lines

  1. unit SrvMain;
  2. interface
  3. uses
  4.   ComObj, ActiveX, Srv_TLB, StdVcl;
  5. type
  6.   TRegObj = class(TAutoObject, IRegObj)
  7.   private
  8.     FRegCookie: Integer;
  9.   protected
  10.     procedure AddString(const Value: WideString); safecall;
  11.   public
  12.     destructor Destroy; override;
  13.     procedure Initialize; override;
  14.   end;
  15.  
  16. implementation
  17. uses ComServ, Dialogs, SrvU;
  18. { TRegObj }
  19. destructor TRegObj.Destroy;
  20. begin
  21.   RevokeActiveObject(FRegCookie, nil);
  22.   inherited Destroy;
  23. end;
  24.  
  25. procedure TRegObj.Initialize;
  26. begin
  27.   inherited Initialize;
  28.   OleCheck(RegisterActiveObject(Self, CLASS_RegObj, ACTIVEOBJECT_WEAK, FRegCookie));
  29. end;
  30.  
  31. procedure TRegObj.AddString(const Value: WideString);
  32. begin
  33.   MainForm.Memo.Lines.Add(Value);
  34. end;
  35.  
  36. initialization
  37.   TAutoObjectFactory.Create(ComServer, TRegObj, Class_RegObj,
  38.     ciMultiInstance, tmApartment);
  39. end.
  40.